package com.gps.skyrc.view.loading;

import android.app.Dialog;
import android.content.Context;

import com.gps.skyrc.R;


/**
 * 类描述：等待框
 * 创建人：ZZ
 * 创建时间：2017-04-22 8:44
 * 修改人：Administrator
 * 修改时间：2017-04-22 8:44
 * 修改备注：
 */

public class LoadingDialog extends Dialog {
    private static LoadingDialog mLoadDialog;

    private LoadingDialog(Context context) {
        this(context, false, R.style.LoadingDialog);
    }

    private LoadingDialog(Context context, boolean flag, int theme) {
        super(context, theme);
        this.setContentView(R.layout.view_loading);
        setCanceledOnTouchOutside(false);
        this.setCancelable(flag);
        //this.getWindow().getAttributes().gravity = Gravity.CENTER;
        // TextView tvMsg = (TextView) this.findViewById(R.id.id_tv_loading_msg);
        //if (tvMsg != null) {
        //tvMsg.setText(strMessage);
        //}
    }

    public static void showDialog(Context context) {
        if (context == null)
            return;
        if (null != mLoadDialog && mLoadDialog.isShowing())
            return;
        mLoadDialog = new LoadingDialog(context);
        mLoadDialog.show();
    }

    public static void dismissDialog() {
        if (null != mLoadDialog && mLoadDialog.isShowing()) {
            mLoadDialog.dismiss();
            mLoadDialog = null;
        }
    }
}
